-
-
Notifications
You must be signed in to change notification settings - Fork 968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly return sprites as an object when querying it using GraphQL #959
Conversation
The |
Yeah I ran into that when trying to play around with the change without the docker containers at first. Idk how we want to handle this, as postgres does support it, which is what the docker containers use. Do we want to support two different setups? |
@Naramsim do you have a suggestion? |
Hi, I haven't had the time to test the pr locally. For this week I'm off 😭 Do we really need to change the schema of the DB in such a way that SQLite stops working? |
Tbh I'd like to continue to support SQLite, since for local testing is pretty handy. Maybe there's a plugin for enabling jsonb? |
https://sqlite.org/draft/jsonb.html this? Idk |
That's crazy, that talks about introducing support for JSONB in version 3.44.0, which just came out on the first of this month and is the newest version! 😮 |
I think our problem is the Django version (currently 2.2). Django 3.1 introduced support for JSON field: https://docs.djangoproject.com/en/3.1/ref/models/fields/#jsonfield
I don't think Django 2.2 would support that 😅 |
Otherwise I could just use this branch for the graphql server. Or maybe we could put everything conditionally! If the db is postgresql, run the migration and insert JSONs directly. If it's SQLite we don't run the migration and we insert strings. I'd go with the second one if you have some more time to spend on the code 😁😁😁😁 |
Yeah if we want to support two types, then we could probably use If we do split the branches, then we'd have to maintain two different branches when one gets updated. |
@Naramsim @C-Garza are we not OK with upgrading the Django version? Because I upgraded it to 3.1 and got the tests running again in SQLite. One test broke and needs fixing:
|
Hmm, if everything works fine still I don't see any harm updating it. But I am not that familiar with all the django packages being used. |
If you can you're most welcome to upgrade Django :) I tried sometime ago but had some difficulties, I don't remember which ones though. :( |
Tests are now passing and we are on Django 3.1. Please don't merge it yet, it seems I broke the Docker image during the upgrade but I'm not sure if it's an actual error or a me error. Also, I've noticed we don't use all packages listed in |
😮 That's so nice! Thanks a lot for the hard job!!! |
Hi! I pushed this code to the |
@Naramsim the deploy step is trying to pull the
Which has not been generated in the last 12 days (at the moment of writing). I think this is why my Docker environment is also broken. |
Can you try with the docker compose dev? docker-compose -f docker-compose.yml -f docker-compose-dev.yml up -d |
@Naramsim with the command you provided the image did build locally and there was no error. Already performed the cleanup of the |
@simonorono , if you still have time could you do the same job for the item sprites and the pokemon forms? 🫣😁 |
@Naramsim I forgot about those. Done. |
Ok I was wrong and it was not done. Now it is 😅 |
…sonb` This is so Hasura automatically transforms the field into an array instead of a JSON encoded in a string. Migration was generated by the `makemigrations` command.
Since the column is now jsonb, we need to stop encoding it or it gets inserted as a string rather than a JSON object.
Some third-party packages had to be updated and some new settings were added due to `manage.py` not running.
This was preventing the tests from running.
The models affected were PokemonFormSprites and ItemSprites. This was done to ensure they are properly returned when querying those tables with Hasura.
Moved the declaration of sprite_data variables closer to their actual usage.
d8f605c
to
b3d6608
Compare
Hey @simonorono , would you like to join the pokeapi org ? |
Yes :) thank you. |
Needed to accomplish this:
sprites
column inpokemon_v2_pokemonsprites
table to JSONB. That makes Hasura to automatically return it as an object.pokemon_v2_pokemonsprites
table. It was inserting a string in the field making it be non-valid JSON causing Hasura to return it as a string.get_pokemon_sprites
to return thesprites
field in thePokemonSprite
object directly.Closes #614